<?php

namespace app\admin\controller\Utils;

use think\helper\Str;

class JavaCompatible
{
    /**
     * 驼峰转下划线
     * @param $data
     * @return array
     */
    public static function snake($data): array
    {
        $result = [];
        foreach ($data as $k => $v) {
            $key = Str::snake($k);
            $result[$key] = $v;
        }

        return $result;
    }

    /**
     * 下划线转驼峰
     * @param $data
     * @return array
     */
    public static function camel($data): array
    {
        $result = [];
        foreach ($data as $k => $v) {
            $key = Str::camel($k);
            $result[$key] = $v;
        }

        return $result;
    }
}